#ifndef CSERVER_SESSION_TIMER_H
#define CSERVER_SESSION_TIMER_H
#include <boost/asio/io_service.hpp>
#include <boost/asio/spawn.hpp>
#include <boost/asio/system_timer.hpp>
#include <map>
#include <vector>

namespace csrv{
	class Context;
	class WallTimer{
		Context& context;
		using handler_type = std::function<void()>;
		using handlers_list = std::vector<handler_type>;
		std::map<boost::asio::system_timer::time_point, handlers_list> timers;
		boost::asio::system_timer sys_timer;
		public:
		explicit WallTimer(Context& ctx);
		void start();

		void append(boost::asio::system_timer::time_point, std::function<void()> f);
		private:
		void run_(boost::asio::yield_context yield);
	};
	using WallTimerPtr = std::shared_ptr<WallTimer>;


}
#endif // end CSERVER_SESSION_TIMER_H


